home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / parser / parser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-02-08  |  2.6 KB  |  120 lines

  1. # include    <stdio.h>
  2. # include    <ingres.h>
  3. # include    <range.h>
  4. # include    <tree.h>
  5. # include    <func.h>
  6. # include    <pv.h>
  7. # include    "parser.h"
  8. # include    <sccs.h>
  9. # include    <errors.h>
  10.  
  11. SCCSID(@(#)parser.c    8.3    2/8/85)
  12.  
  13. short            tTparser[100];
  14.  
  15. extern int        parser();
  16. extern int        par_init();
  17.  
  18. struct fn_def        ParserFn =
  19.             {
  20.                 "PARSER",
  21.                 parser,
  22.                 par_init,
  23.                 NULL,
  24.                 NULL,
  25.                 0,
  26.                 tTparser,
  27.                 100,
  28.                 'P',
  29.                 0
  30.             };
  31.  
  32. DESC    Reldesc;
  33. struct atstash        Attable[MAXATT];/* attrib stash space, turned into a list later */
  34. struct atstash        *Freeatt;    /* free list of attrib stash */
  35. QTREE    *Tidnode;    /* pointer to tid node of targ list
  36.                        for REPLACE, DELETE */
  37. QTREE    *Lastree;    /* pointer to root node of tree */
  38. DELIMLIST     *Delimhead;    /* pointer to head of Delim queue */
  39. static int    FirstCall = 1;  /* true for the very first call of the parser */
  40. extern struct atstash    Faketid;    /* atstash structure for TID node */
  41. #ifdef    DISTRIB
  42. extern struct atstash    Fakesid;    /* atstash structure for SID node */
  43. #endif
  44.  
  45. int            Rsdmno;        /* result domain number */
  46. int            Opflag;        /* operator flag contains query mode */
  47. char            *Relspec;    /* ptr to storage structure of result relation */
  48. char            *Indexspec;    /* ptr to stor strctr of index */
  49. char            *Indexname;    /* ptr to name of index */
  50. char            Trfrmt;        /* format for type checking */
  51. char            Trfrml;        /* format length for type checking */
  52. char            *Trname;    /* pointer to attribute name */
  53. int            Agflag;        /* how many aggs in this qry */
  54. int            Equel;        /* indicates EQUEL preprocessor on */
  55. int            Ingerr;        /* set to error num if a query returns
  56.                        an error from processes below */
  57. int            Qlflag;        /* set when processing a qual */
  58. int            Noupdt;        /* INGRES user override of no update restriction */
  59. int            Err_fnd;    /* no actions done if 1 */
  60. int            Err_current;    /* 1 if error found in current statement */
  61. int            yyline;        /* line counter */
  62. int            Dcase;        /* default case mapping */
  63. int            Permcomd;
  64. int            Qrymod;        /* qrymod on in database flag */
  65. TID            tid;
  66. char            *malloc();
  67.  
  68.  
  69. /*
  70. **  PARSER -- the actual main routine
  71. **
  72. **    Trace Flags:
  73. **        Parser ~~ 64
  74. */
  75.  
  76. parser()
  77. {
  78.  
  79.     int    i;
  80.  
  81.  
  82. # ifdef    xPTR1
  83.     tTfp(64, 0, "Parser %d\n", getpid());
  84. # endif
  85.  
  86.     if (FirstCall)
  87.     {
  88.         FirstCall = 0;
  89.         if ((i = openr(&Reldesc, OR_WRITE, "rdelim")) < 0)
  90.         syserr("relname: error in openr '%d'", i);
  91.         if (i > 0)
  92.         {
  93.             /* invalid relation name */
  94.             par_error(RNGEXIST, WARN, "rdelim", 0);
  95.         }
  96.         else
  97.         {
  98.             if ((i = make_list(&Reldesc, "system")) < 0)
  99.                 par_error(DELEXIST, WARN, 0);
  100.         }
  101.         closer(&Reldesc);
  102.     }
  103.     if (startgo() < 0)
  104.     {
  105.         endgo();
  106.         return (-1);
  107.     }
  108.  
  109.     if (yyparse())        /* yyparse returns 1 in case of error */
  110.     {
  111.         endgo();
  112.         return (-2);
  113.     }
  114.  
  115.     if (endgo() < 0)
  116.         return (-3);
  117.  
  118.     return(0);
  119. }
  120.